import 'package:finance_app/generated/json/base/json_convert_content.dart';
import 'package:finance_app/generated/json/base/json_field.dart';
import 'package:finance_app/src/entities/ocr_attachment_entity.dart';
import 'package:finance_app/src/entities/report_list_item_entity.dart';
import 'package:finance_app/src/entities/tax_submission_detail_entity.dart';

class DataReportEntity with JsonConvert<DataReportEntity> {
  List<ReportListItemEntity> body;
  dynamic meta;
  @JSONField(name: "start_date")
  String startDate;
  List<OcrAttachmentEntity> attachments;

  set total(DataReportTotal data) {}

  DataReportTotal get total {
    if (meta != null && meta is Map && meta['total'] != null) {
      return DataReportTotal().fromJson(meta['total']);
    }
    return null;
  }

  set detail(TaxSubmissionDetailEntity data) {}

  TaxSubmissionDetailEntity get detail {
    if (meta != null && meta is Map && meta['tax_submission'] != null) {
      return TaxSubmissionDetailEntity().fromJson(meta);
    }
    return null;
  }
}

class DataReportTotal with JsonConvert<DataReportTotal> {
  int current;
  @JSONField(name: "days_30")
  int days30;

  @JSONField(name: "days_60")
  int days60;

  @JSONField(name: "days_61")
  int days61;
  dynamic meta;

  int get total => current + days30 + days60 + days61;
}
